<template>
	<view class="container">
		<view class="tit v-center">请认真输入提现银行信息，并再次核对。</view>
		<view class="cont">
			<view class="box">
				<view class="tit1">提现银行卡管理</view>
				<view class="i-box">
					<view class="space-between">
						<view class="text"><text class="xing">*</text>开户名</view>
						<input type="text" v-model="bankAcc" class="input" placeholder="请输入银行卡户名" />
					</view>
					<view class="space-between">
						<view class="text"><text class="xing">*</text>银行</view>
						<input type="text" v-model="bankName" class="input" placeholder="请输入银行" />
					</view>
					<view class="space-between">
						<view class="text"><text class="xing">*</text>卡号</view>
						<input type="number" v-model="bankNo" class="input" placeholder="请输入卡号" />
					</view>
				</view>
			</view>
		</view>
		<view class="bottom center" @click="open">
			<view class="center btn">保存</view>
		</view>
		<uni-popup ref="popup" type='center' border-radius="30rpx 30rpx 30rpx 30rpx">
			<view class="popup-box">
				<view class="title">再次确认信息</view>
				<view class="xx">
					<view class="text">{{bankAcc}} <text class="bank">{{bankName}}</text></view>
					<view class="num">{{bankNo}}</view>
				</view>
				<view class="p-bottom space-between">
					<view class="center" @click="close">返回修改</view>
					<view class="center sure" @click="sure">确定保存</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {
		bandCard,
		getUserInfo
	} from '../../api/active.js'
	import uniPopup from '../../uni_modules/uni-popup/components/uni-popup/uni-popup.vue';
	export default {
		comments: {
			uniPopup
		},
		data() {
			return {
				bankAcc: "",
				bankName: "",
				bankNo: "",
				userInfo: ''
			}
		},
		onLoad() {
			// this.$refs.popup.open('center')
			getUserInfo({userId: uni.getStorageSync("userId")}).then(res=>{
				this.bankAcc = res.data.bankAcc
				this.bankName = res.data.bankName
				this.bankNo = res.data.bankNo
			})
		},
		methods: {
			close() {
				this.$refs.popup.close()
			},
			open() {
				if (!this.bankAcc || !this.bankName || !this.bankNo) return uni.showToast({
					title: '请将必填信息填写完整',
					icon: 'none',
				})
				this.$refs.popup.open('center')
			},
			sure() {
				bandCard({
					bankAcc: this.bankAcc,
					bankName: this.bankName,
					bankNo: this.bankNo,
					userId: uni.getStorageSync("userId")
				}).then(() => {
					uni.showToast({
						title: '绑定成功',
						icon: 'none',
						duration: 1500
					})
					setTimeout(() => {
						uni.navigateBack()
					}, 1500)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.popup-box {
		width: 690rpx;
		height: 462rpx;
		background: #F8F8F8;
		border-radius: 30rpx;
		text-align: center;
		padding-top: 46rpx;

		.title {
			font-weight: 800;
			font-size: 40rpx;
			color: #333333;
		}

		.xx {
			width: 568rpx;
			height: 166rpx;
			background: #EDEDED;
			border-radius: 10rpx;
			margin: 40rpx auto 0 auto;
			padding: 40rpx 0 0 40rpx;
			text-align: left;

			.text {
				font-weight: 800;
				font-size: 28rpx;
				color: #333333;

				.bank {
					font-size: 26rpx;
					font-weight: 500;
					padding-left: 10rpx;
				}
			}

			.num {
				font-weight: 800;
				font-size: 36rpx;
				color: #333333;
				margin-top: 20rpx;
			}
		}

		.p-bottom {
			width: 100%;
			border-top: 2rpx solid #DDDDDD;
			height: 114rpx;
			align-items: center;
			margin-top: 40rpx;

			.center {
				width: 50%;
				font-weight: 500;
				font-size: 34rpx;
				color: #999999;

				&.sure {
					color: #333333;
				}
			}
		}
	}

	.container {
		width: 100vw;
		background: #f5f5f5;
		min-height: 100vh;
	}

	.tit {
		width: 100%;
		height: 70rpx;
		background: #F7E6C5;
		font-weight: 500;
		font-size: 30rpx;
		color: #8A6625;
		padding-left: 50rpx;
	}

	.cont {
		padding: 20rpx 24rpx 0 24rpx;
	}

	.box {
		width: 100%;
		height: 405rpx;
		background: #FFFFFF;
		border-radius: 15rpx;
		padding: 32rpx 24rpx 0 24rpx;

		.tit1 {
			font-weight: 500;
			font-size: 34rpx;
			color: #333333;
		}

		.i-box {
			margin-top: 26rpx;

			.space-between {
				height: 100rpx;
				border-bottom: 2rpx solid #E9E9E9;
				align-items: center;
			}

			.space-between:last-child {
				border-bottom: none;
			}

			.text {
				font-weight: 500;
				font-size: 28rpx;
				line-height: 36rpx;
				color: #333333;

				.xing {
					color: #FF0000;
				}
			}

			.input {
				text-align: right;
				font-size: 28rpx;
				width: 400rpx;
			}
		}
	}

	.bottom {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100vw;
		height: 130rpx;
		background: #FFFFFF;

		.btn {
			width: 690rpx;
			height: 90rpx;
			background: #005097;
			border-radius: 45rpx;
			font-weight: 800;
			font-size: 30rpx;
			color: #FFFFFF;
		}
	}
</style>